package com.bdqn.controller;

import com.bdqn.pojo.Menu;
import com.bdqn.service.MenuService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin //允许跨域
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    MenuService menuService;

    @GetMapping("/getUserMenus")
    public List<Menu> getUserMenus(int uid){
        List<Menu> menu=menuService.getUserMenus(uid);
        return menu;
    }

    @GetMapping("/getMenus")
    public List<Menu> getMenus(){
        List<Menu> list=menuService.getMenusAll();
        return list;
    }

    @GetMapping("getMenuPage")
    public PageInfo<Menu> getMenuPage(int pageNum, int pageSize, String mname){
        PageInfo<Menu> menus=menuService.selectPage(pageNum,pageSize,mname);
        return menus;
    }
}
